home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group93c.txt
/
000115_icon-group-sender _Mon Dec 13 08:31:53 1993.msg
< prev
next >
Wrap
Internet Message Format
|
1994-02-02
|
4KB
Received: by cheltenham.cs.arizona.edu; Tue, 14 Dec 1993 18:01:36 MST
Date: 13 Dec 93 08:31:53 GMT
From: csus.edu!netcom.com!rfg@decwrl.dec.com (Ronald F. Guilmette)
Organization: NETCOM On-line Communication Services (408 241-9760 guest)
Subject: Need help with (simple?) programming problem.
Message-Id: <rfgCHyt15.Fpz@netcom.com>
Sender: icon-group-request@cs.arizona.edu
To: icon-group@cs.arizona.edu
Status: RO
Errors-To: icon-group-errors@cs.arizona.edu
My thanks to to the several people who replied to my earlier request for
general information about the nature of ICON.
I have obtained Griswold's 2nd Edition book, and (believe it or not) I
already plowed most of the way through it (although I confess that I only
skimmed most of the parts relating to string scanning). The book is well
written, which I appreciate greatly.
Naturally, as with every language I've ever studied, there are a few minor
things I might change (adding enum types for example) but I'll save those
comments for another message (to be posted someday after I feel like I've
reached at least the ICON brown-belt level).
Anyway, today I need/want to solve a real problem, and I'm hoping one or
more of you ICON gurus will lend me a hand.
In a nutshell, here's what I want to do...
Assume that I have three strings, i.e. "red ", "green ", and "blue ". Now
I want to create a generator which will successively yield each unique
string which contains no more than one instance of each of the original
strings. Here are the string values which should be yielded by the various
invocations/resumptions of the generator:
""
"red "
"green "
"blue "
"red green "
"red blue "
"green red "
"green blue "
"blue red "
"blue green "
"red green blue "
"red blue green "
"green red blue "
"green blue red "
"blue red green "
"blue green red "
After being invoked/resumed 16 times (and yielding each of the above strings
once) the generator should fail. Note that the actual *order* in which the
above strings are yielded is totally unimportant. Any order will do as long
as I get these 16 strings (eventually).
Also note that the ORDER in which the original strings appear in the genera-
ted strings *is* significant.
This is just an example of the kind of thing I want to learn how to do.
Basically, I'm hoping that someone will be able to show me some GENERAL
techinque for creating a generator along these lines. (In practice, for
my *real* problem, the number of original strings will in fact be larger
than three... but it *will* be a fixed number (probably less that 12).
Is there a simple solution and/or well-known idiom for this general class
of problems in ICON? If so, some example code would be most enlightening.
P.S. It probably makes no difference, but in the case of my *real* problem,
one or more of the "original strings" may not actually be strings at all.
They may instead be generators which produce various strings. But the
rules of the game will remain essentially the same, i.e. the strings
yielded by my new generator must never contain any more than one instance
of any one of the "inputs" (where an "input" could be either a literal
string, or any one of the strings yielded by a given "input generator".
For example:
procedure greenish_input_generator ()
suspend "green " | "light-green "
end
I never want to see any more than one greenish color in the strings yielded
by my new generator.
--
-- Ronald F. Guilmette, Sunnyvale, California -------------------------------
------ domain address: rfg@netcom.com ---------------------------------------
------ uucp address: ...!uunet!netcom.com!rfg -------------------------------